Home | | Latest | About | Random
# Week 2 Wednesday
## Euler's formula.
_Forget, and perish:_ $$
e^{it} = \cos(t) + i\sin(t).
$$This is Euler's identity. Here $i^{2}=-1$.
One can justify this equation by noting the power series of $e^{z}$ in general is $$
e^{z} = 1 + z+\frac{1}{2!}z^{2} + \frac{1}{3!}z^{3}+\frac{1}{4!}z^{4} +\cdots
$$
(you should memorize it for good), and the trigonometric functions have $$
\sin(z) = z - \frac{1}{3!} z^{3} +\frac{1}{5!}z^{5}-\frac{1}{7!}z^{7}+\cdots
$$
and $$
\cos(z) = 1 - \frac{1}{2!}z^{2}+\frac{1}{4!}z^{4}-\frac{1}{6!}z^{6}+\cdots
$$
So upon substituting $z = it$ into the power series of $e^{z}$, we get $$
\begin{align*}
e^{it} &= 1 + it+\frac{1}{2!}(it)^{2} + \frac{1}{3!}(it)^{3}+\frac{1}{4!}(it)^{4}+\cdots \\
&= 1 +it -\frac{1}{2!}t^{2}-\frac{i}{3!}t^{3}+\frac{1}{4!}t^{4}+\frac{i}{5!}t^{5}+\cdots \\
&=\left( 1-\frac{1}{2!}t^{2}+\frac{1}{4!}t^{4}-\cdots \right) + i\left( t-\frac{1}{3!}t^{3} + \frac{1}{5!}t^{5} - \cdots \right) \\
&=\cos(t) + i\sin(t)
\end{align*}
$$provided we believe, of course, that the series above converges for complex numbers.
Euler's identity allows an algebratization of trigonometry. If we believe (which it does work) exponential rules for complex exponentials, then note $$
e^{i(a+b)} = e^{ia} e^{ib}
$$But this means $$
\begin{align*}
&\cos(a+b)+i\sin(a+b) = \\
&= (\cos(a) + i\sin(a))(\cos(b) + i\sin(b)) \\
& = \cos(a)\cos(b) - \sin(a)\sin(b) + i(\cos(a)\sin(b) + \sin(a)\cos(b))
\end{align*}
$$
So by matching real parts together and imaginary parts together, we have $$
\begin{align*}
\cos(a+b) = \cos(a) \cos(b) - \sin(a) \sin(b) \\
\sin(a+b) = \cos(a)\sin(b) + \sin(a) \cos(b)
\end{align*}
$$
Using this idea we can compute various trigonometric identities, angle sum, double angle, triple angle formulas.
## Drawing slope field.
- To draw slope field for $y'=f(x,y)$, we need to plot a line segment of slope $f(x_{0},y_{0})$ at the location $(x_{0},y_{0})$ on the plane. To do this we need a line segment at an angle $a =\arctan(f(x_{0},y_{0}))$. So draw out the line segment from $(x_{0}-r \cos(a),y_{0} - r \sin(a))$ to the point $(x_{0} + r\cos(a),y_{0} + r\sin(a))$, for some segment of length $2r$.
## Euler's method.
Given a slope field describing a differential equation $y'=f(x,y)$.
- How do we plot out the slope field.
- How do we numerically find a solution, given some starting initial condition $(x_{0},y_{0})$?
- Note since the solution curve $y$ is differentiable at $x=x_{0}$, it is **locally linear**, hence we can perform a linear approximation of $y(x)$ at $x_{0}$ by $y(x) \approx L(x)=y(x_{0})+y'(x_{0})(x-x_{0})$. Since $y'(x_{0})=f(x_{0},y_{0})$, we see that $y(x_{0}+\Delta x) \approx L(x_{0}+\Delta x) = y(x_{0}) + f(x_{0},y_{0})\Delta x$. In other words, we can approximate a nearby point on the curve of $y$ by $(x_{1},y_{1})=(x_{0} + \Delta x, y(x_{0}) + f(x_{0},y_{0}) \Delta x)$.
- So, starting with the initial point $(x_{0},y_{0})$, we can approximate a sequence of points on the solution curve $(x_{1},y_{1}),(x_{2},y_{2}),\ldots$ by $$
(x_{n+1},y_{n+1}) = (x_{n} + \Delta x , y_{n} + f(x_{n},y_{n})\Delta x)
$$for some fixed step size $\Delta x$. This is **Euler's method**.
- This method is "better" the smaller the step size we use. In fact each step we accumulate some error. The error is on the order of $\Delta x$. So this is a first-order method. Namely, the overall error is proportional to the size of $\Delta x$.
## Computer implementation.
- Now that we have above, we can implement on computer.